
#include "SoundManager.h"

CSoundManager::CSoundManager()
	:m_startSound(NULL),
	m_boomSound(NULL),
	m_hitSound(NULL),
	m_fireSound(NULL),
	m_menuClickSound(NULL),
	m_winSound(NULL)
{

}

CSoundManager::~CSoundManager()
{
	SafeDelete(m_winSound);

	SafeDelete(m_menuClickSound);

	SafeDelete(m_fireSound);
	SafeDelete(m_hitSound);
	SafeDelete(m_boomSound);
	SafeDelete(m_startSound);

}


void CSoundManager::InitSoundObjects()
{
	m_pGameState = CGameState::GetGameStateInstance();

	m_startSound = new CSkinMusic();
	m_startSound->PlayMedia("res\\sound\\start.mp3");

	m_menuClickSound = new CSkinMusic();
	m_menuClickSound->PlayMedia("res\\sound\\menuclick.mp3");

	m_boomSound = new CSkinMusic();
	m_boomSound->PlayMedia("res\\sound\\Bang.wav");

	m_hitSound = new CSkinMusic();
	m_hitSound->PlayMedia("res\\sound\\hit.wav");

	m_fireSound = new CSkinMusic();
	m_fireSound->PlayMedia("res\\sound\\fire.mp3");

	m_winSound = new CSkinMusic();
	m_winSound->PlayMedia("res\\sound\\Fanfare.wav");

}


void CSoundManager::RunSound()
{
	if (true == m_pGameState->GetStartNewGameSound())
	{
		m_startSound->Stop();
		m_startSound->Run();
		m_pGameState->SetStartNewGameSound(false);
	}
	if (true == m_pGameState->GetCharacterDieSound())
	{
		m_boomSound->Stop();
		m_boomSound->Run();
		m_pGameState->SetCharacterDieSound(false);
	}
	if (true == m_pGameState->GetHunterWinSound())
	{
		m_winSound->Stop();
		m_winSound->Run();
		m_pGameState->SetHunterEatSound(false);
	}
	if (true == m_pGameState->GetBulletHitSound())
	{
		m_hitSound->Stop();
		m_hitSound->Run();
		m_pGameState->SetBulletHitSound(false);
	}
	if (true == m_pGameState->GetHunterFireSound())
	{
		m_fireSound->Stop();
		m_fireSound->Run();
		m_pGameState->SetHunterFireSound(false);
	}
	if (true == m_pGameState->GetMenuClickSound())
	{
		m_menuClickSound->Stop();
		m_menuClickSound->Run();
		m_pGameState->SetMenuClickSound(false);
	}

}